﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HKEA.CMS.Core.IDAL.Tbl;
using HKEA.CMS.Core.IDAL.App;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.DALFactory;
using HKEA.CMS.Core.Utility;

namespace HKEA.CMS.Core.BLL.App
{
    public class app_tblCust_BusNatureBLL
    {
        private Iapp_tblCust_BusNature IDAL;
        public app_tblCust_BusNatureBLL()
        {
            IDAL = DataAccess.CreateIapp_tblCust_BusNature();
        }
        public static app_tblCust_BusNatureBLL GetInstance() {
            return new app_tblCust_BusNatureBLL();
        }

        public int InsertENT(app_tblCust_BusNature ent) {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.InsertENT(ent);
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return ret;
        }

        public bool SaveList(List<int> AddList,List<int> DelList,int CustomerUID,string LastModifyBy)
        {
            bool ret=true;
            try{
                IDAL.SaveList(AddList,DelList,CustomerUID,LastModifyBy);
            }
            catch(Exception er)
            {
                ret=false;
            }
            return ret;
        }
        
        public int SaveList(List<int> BusNatureUIDList, int CustomerUID, string LastModifyBy)
        {
            int ret = 0;
            if (BusNatureUIDList != null)
            {
                try
                {
                    ret = IDAL.InsertENT(BusNatureUIDList, CustomerUID, LastModifyBy);
                }
                catch (Exception er) { throw er; };
            }
            return ret;
        }

        /// <summary>
        /// 物理删除
        /// </summary>
        /// <param name="ent"></param>
        /// <returns></returns>
        public int DeleteENT(app_tblCust_BusNature ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.DeleteENT(ent);
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return ret;
        }
        /// <summary>
        /// 修改记录
        /// </summary>
        /// <param name="ent"></param>
        /// <returns></returns>
        public int UpdateENT(app_tblCust_BusNature ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.UpdateENT(ent);
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return ret;
        }
        /// <summary>
        /// 根据条件得到符合条件的结果集，带分页参数
        /// </summary>
        /// <param name="ent"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<app_tblCust_BusNature> GetListByENT(app_tblCust_BusNature ent, PageParam param, string strPropertyName, string strOrderBy)
        {
            List<app_tblCust_BusNature> list = new List<app_tblCust_BusNature>();
            if (ent != null && param != null)
            {
                try
                {
                    list = IDAL.GetListByENT(ent, param, strPropertyName, strOrderBy);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return list;
        }
        /// <summary>
        /// 根据条件得到符合条件的结果集
        /// </summary>
        /// <param name="ent"></param>
        /// <param name="NeedDelete">是否将Deleted 加入 查询条件;</param>
        /// <returns></returns>
        public List<app_tblCust_BusNature> GetListByENT(app_tblCust_BusNature ent, bool NeedDelete)
        {
            List<app_tblCust_BusNature> list = new List<app_tblCust_BusNature>();
            if (ent != null)
            {
                try
                {
                    list = IDAL.GetListByENT(ent, NeedDelete);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return list;
        }
        /// <summary>
        /// 根据条件得到符合条件的记录条数
        /// </summary>
        /// <param name="ent"></param>
        /// <param name="NeedDelete">是否将Deleted 加入 查询条件;</param>
        /// <returns></returns>
        public int GetCountByENT(app_tblCust_BusNature ent, bool NeedDelete)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.GetCountByENT(ent, NeedDelete);
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return ret;
        }
        /// <summary>
        /// 判断是否已存在符合条件的记录
        /// </summary>
        /// <param name="ent"></param>
        /// <param name="NeedDelete">是否将Deleted 加入 查询条件;</param>
        /// <returns></returns>
        public bool IsExist(app_tblCust_BusNature ent, bool NeedDelete)
        {
            bool ret = false;
            if (ent != null)
            {
                if (GetCountByENT(ent, NeedDelete) > 0)
                    ret = true;
            }
            return ret;
        }
        public List<int> GetCustomerUIDList()
        {
            try { return IDAL.GetCustomerUIDList(); }
            catch (Exception er) { }
            return null;
        }
    }
}
